package org.micode.demo.db.domain.query;

import lombok.Data;
import lombok.EqualsAndHashCode;
import org.micode.common.domain.base.BaseQuery;
import org.micode.common.utils.StringExtUtils;
import org.micode.demo.db.domain.entity.SysDictionaryDO;

import java.util.ArrayList;
import java.util.List;

/**
 * 字典配置信息(sys_dictionary) 查询类
 * <p>
 * @author: wutianbin
 * @version: v1.0.24
 * @CreateDate: 2021-09-06
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class SysDictionaryQuery extends BaseQuery<SysDictionaryDO> {

    /** 模糊匹配"参数编码"或"参数名称" */
    private String paramName;

    @Override
    public List<String> getExtConditions() {
        if (!StringExtUtils.isAnyEmpty(paramName)) {
            return new ArrayList<String>() {{
                add("(param_name like '%" + paramName + "%'" +
                        "or param_key like '%" + paramName + "%')");
            }};
        }
        return null;

    }

    @Override
    public void initForNewQuery() {
        this.setExample(new SysDictionaryDO());
    }

}
